﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.Simulator
{
    static class ActorReferencePointExt
    {
        public static void GetReferencePoint(this Actor actor, int index, out float x, out float y)
        {
            if (index < 0 || index > 2)
            {
                x = actor.X;
                y = actor.Y;
                return;
            }
            var transformation = actor.CurrentFrame.ImageTransformation;
            float scaleX = actor.ScaleX, scaleY = actor.ScaleY;
            if (transformation != null)
            {
                scaleX *= transformation.Scale.X / 100.0f;
                scaleY *= transformation.Scale.Y / 100.0f;
            }
            var point = actor.CurrentFrame.Points[index].Position;
            x = actor.X + scaleX * point.X;
            y = actor.Y + scaleY * point.Y;
            return;
        }
    }
}
